﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;

public partial class UserControl_ControlDieuChinhTonKho : System.Web.UI.UserControl
{
    

    ClassExecute.ClassExecute dt;
    string str = webapp4U.Configuration.CurrentConnectionString;
    string error = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        
        
    }
    protected void imgBtnAdd_Click(object sender, ImageClickEventArgs e)
    {
        dt = new ClassExecute.ClassExecute();
         try
         {

             DataTable db = dt.Get_Data_DataTable(str, ref error, "k_getQtyStockForUpdate", CommandType.StoredProcedure);
             if (db.Rows.Count > 0)
             {
                 grvProduct.DataSource = db;

             }
             else
             {
                 grvProduct.DataSource = null;

             }
             grvProduct.DataBind();
         }
         catch (Exception ex)
         {
             
             string method = System.Reflection.MethodBase.GetCurrentMethod().Name;
             dt.WriteErrorLog(Server.MapPath(webapp4U.Globals.LogUrl()), ex.Message, method);
         }
    }
    protected void ImgBtnApprove_Click(object sender, ImageClickEventArgs e)
    {
        dt = new ClassExecute.ClassExecute();
        DateTime date1 = new DateTime(int.Parse(txtNgay.Text.Substring(6, 4)), int.Parse(txtNgay.Text.Substring(3, 2)), int.Parse(txtNgay.Text.Substring(0, 2)));
        DateTime date2= date1.AddDays(1);
        try
        {

        }
        catch (Exception ex)
        {

            string method = System.Reflection.MethodBase.GetCurrentMethod().Name;
            dt.WriteErrorLog(Server.MapPath(webapp4U.Globals.LogUrl()), ex.Message, method);
        }
       
    }
    void ShowMessageBox(string text)
    {
        MessageBox.Text = text;
        MessageBox.ShowOnPageLoad = true;
    }
    public int CompareDate(string sdate1,string sdate2)
    {
        DateTime date1 = new DateTime(int.Parse(sdate1.Substring(6, 4)), int.Parse(sdate1.Substring(3, 2)), int.Parse(sdate1.Substring(0, 2)));
        DateTime date2 = new DateTime(int.Parse(sdate2.Substring(6, 4)), int.Parse(sdate2.Substring(3, 2)), int.Parse(sdate2.Substring(0, 2)));
        int result = DateTime.Compare(date1, date2);
        return result;

        //if (result < 0)
        //    relationship = "sdate1 is earlier than";
        //else if (result == 0)
        //    relationship = "is the same time as";
        //else
        //    relationship = "sdate 1 is later than";

    }



    
}